<?php

declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class CreateVipOrderTableMigration extends AbstractMigration
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change(): void
    {
        $this->table('vip_order', ['id' => false, 'primary_key' => ['id'], 'comment' => '会员VIP订单表','engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci'])
            ->addColumn('id', 'integer', ['identity' => true])
            ->addColumn('user_id', 'integer', ['comment' => '用户ID'])
            ->addColumn('order_no', 'string', ['limit' => 255, 'comment' => '订单号'])
            ->addColumn('money', 'decimal', ['precision' => 10, 'scale' => 2, 'comment' => '订单金额'])
            ->addColumn('status', 'string', ['limit' => 16, 'default' => 'unpay', 'comment' => '订单状态'])
            ->addColumn('created_at', 'integer', ['default' => '0', 'limit' => 11, 'comment' => '创建时间'])
            ->addColumn('updated_at', 'integer', ['default' => '0', 'limit' => 11, 'comment' => '更新时间'])
            ->create();
    }
}
